﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DocumentLayer
{
    public class DocumentManager
    {
        private static Microsoft.Office.Interop.Word._Application appWord;
        public static void OpenDocument(object filename)
        {

            filename = filename.ToString().Replace(" ", string.Empty);
            appWord = null;
            Microsoft.Office.Interop.Word._Document docWord = null;

            Object ConfirmConversions = System.Reflection.Missing.Value;
            Object ReadOnly = false;
            Object missing = System.Reflection.Missing.Value;
            Object Visible = true;
            Object saveChanges = true;

            appWord = new Microsoft.Office.Interop.Word.Application();
            appWord.Visible = true;
            docWord = appWord.Documents.Open(ref filename, ref missing, ref ReadOnly,
                              ref missing, ref missing, ref missing,
                              ref missing, ref missing, ref missing,
                              ref missing, ref missing, ref Visible,
                              ref missing, ref missing, ref missing, ref missing);



            //Microsoft.Office.Interop.Word.DocumentClass cls = docWord as Microsoft.Office.Interop.Word.DocumentClass;
            //cls.DocumentEvents_Event_Close += new Microsoft.Office.Interop.Word.DocumentEvents_CloseEventHandler(cls_DocumentEvents_Event_Close); 
        }
    }
}
